<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link th:href="@{/erp/assets/css/bootstrap.min.css}" rel="stylesheet"/>
    <link rel="stylesheet" th:href="@{/erp/css/style.css}"/>
    <link rel="stylesheet" th:href="@{/erp/assets/css/ace.min.css}"/>
    <link rel="stylesheet" th:href="@{/erp/assets/css/font-awesome.min.css}"/>
    <link rel="stylesheet" th:href="@{/erp/Widget/zTree/css/zTreeStyle/zTreeStyle.css}" type="text/css">
    <link th:href="@{/erp/Widget/icheck/icheck.css}" rel="stylesheet" type="text/css"/>
    <!--[if IE 7]>
    <link rel="stylesheet" th:href="@{/erp/assets/css/font-awesome-ie7.min.css}"/>
    <![endif]-->
    <!--[if lte IE 8]>
    <link rel="stylesheet" th:href="@{/erp/assets/css/ace-ie.min.css}"/>
    <![endif]-->
    <script th:src="@{/erp/js/jquery-1.9.1.min.js}"></script>
    <script th:src="@{/erp/assets/js/bootstrap.min.js}"></script>
    <script th:src="@{/erp/assets/js/typeahead-bs2.min.js}"></script>
    <!-- page specific plugin scripts -->
    <script th:src="@{/erp/assets/js/jquery.dataTables.min.js}"></script>
    <script th:src="@{/erp/assets/js/jquery.dataTables.bootstrap.js}"></script>
    <script th:src="@{/erp/assets/layer/layer.js}" type="text/javascript"></script>
    <script th:src="@{/erp/assets/laydate/laydate.js}" type="text/javascript"></script>
    <script type="text/javascript" th:src="@{/erp/Widget/zTree/js/jquery.ztree.all-3.5.min.js}"></script>
    <script th:src="@{/erp/js/lrtk.js}" type="text/javascript"></script>
    <title>合作关系审核</title>
    <script type="text/javascript">
        $(function () {
            var divv = document.getElementById("typediv2");
            var div = document.getElementById("typediv1");
            if ($('#aba')[0].checked) {
                divv.style.display = "block";
            } else {
                divv.style.display = "none";
            }
            if ($('#abb')[0].checked) {
                div.style.display = "block";
            } else {
                div.style.display = "none";
            }

            if ($('#status2').text()=='通过'||$('#status2').text()=='拒绝'){
                $('#success').addClass("hidden");
                $('#fail').addClass("hidden")
            }
        })

        var test = function (test) {
            var divv = document.getElementById("typediv2");
            if (test.checked) {
                divv.style.display = "block";
            } else {
                divv.style.display = "none";
            }
        }

        var testt = function (testt) {
            // var di = document.getElementById("ace");
            var div = document.getElementById("typediv1");
            // if(di.checked==di.checked){
            if (testt.checked) {
                div.style.display = "block";
            } else {
                div.style.display = "none";
            }
        }

    </script>
</head>
<body>
<div class="margin clearfix">
    <div class="detailed_style clearfix">
        <em class=""></em>
        <span th:text="${par.tParStatus2}" hidden="hidden" id="status2"></span>
        <p th:text="${par.id}" hidden="hidden" id="id"></p>
        <form hidden="hidden">
            <input name="nodeId" value="" id="nodeId">
        </form>
        <div class="shop_logo"><img th:src="${par.company.companyImage}" width="150" height="150"/></div>
        <ul class="shop_content clearfix">
            <li class="shop_name"><label class="label_name">企业名称：</label><span class="info" th:text="${par.company.companyName}"></span>
                <div class="Authenticate">
                    <i class="icon-yxrz"></i><i class="icon-yhk"></i><i class="icon-sjrz"></i><i class="icon-grxx"></i>
                </div>
            </li>
            <li><label class="label_name">企业类型：</label><span class="info" th:text="${par.company.companyType}"></span></li>
            <li><label class="label_name">经营范围：</label><span class="info" th:text="${par.company.businessScope}"></span></li>
            <li><label class="label_name">申请时间：</label><span class="info" th:text="${par.company.creatTime}"></span></li>
            <li><label class="label_name">状&nbsp;&nbsp;&nbsp;&nbsp;态：</label>&nbsp;&nbsp;
                <span th:class="${par.company.companyStatus}=='on'?'label label-success radius':'label label-danger radius'" th:text="${par.company.companyStatus}=='on'?'已认证':'待认证'"></span></li>
            <li><label class="label_name">申请人姓名：</label><span class="info" th:text="${par.company.legal}"></span></li>
            <li><label class="label_name">成立日期：</label><span class="info" th:text="${par.company.creatTime}"></span></li>
            <li><label class="label_name">电子邮箱：</label><span class="info" th:text="${par.company.companyEmail}"></span></li>
            <li><label class="label_name">固定电话：</label><span class="info" th:text="${par.company.fixedTel}"></span></li>
            <li><label class="label_name">详细地址：</label><span class="info" th:text="${par.company.companyAddress}"></span></li>
        </ul>
    </div>
    <div class="Store_Introduction">
        <div class="title_name">企业简介</div>
        <div class="info">
            <p id="intro" th:text="${par.company.companyIntroduction}"></p>
        </div>
    </div>
    <div class="Store_Introduction">
        <div class="title_name">设定成为</div>
        <div class="info">
            <div class="form-group"><label class="col-sm-1 control-label no-padding-right" for="form-field-1">
                <label><input type="checkbox" th:value="${par.tParRel}" th:checked="${par.tParRel}=='0'" id="aba"
                              class="ace" disabled="disabled"><span class="lbl"></span></label>
                客户</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <label class="col-sm-1 control-label no-padding-right" for="form-field-1">
                    <label><input type="checkbox" th:value="${par.tParRel}" th:checked="${par.tParRel}=='1'" id="abb"
                                  class="ace" disabled><span class="lbl"></span></label>
                    供应商</label>
            </div>
            <div class="form-group"><i style="color:#FF0000">*</i><i style="color:#999999">选择客户可设置对方直购价，发送后对方可见</i>
            </div>
            <div class="form-group"><i style="color:#FF0000">*</i><i style="color:#999999">选择经销商可上传合同附件，通过后可查看直购价</i>
            </div>
        </div>
    </div>
</div>
<br/>
<div class="Store_Introduction" style="display: none;" id="typediv2">
    <div class="title_name">选择客户操作</div>
    <br/>
    <!--产品列表展示-->
    <div class="h_products_list clearfix" id="products_list">
        <div id="scrollsidebar" class="left_Treeview">
            <div class="show_btn" id="rightArrow"><span></span></div>
            <div class="widget-box side_content">
                <div class="side_title"><a title="隐藏" class="close_btn"><span></span></a></div>
                <div class="side_list">
                    <div class="widget-header header-color-green2"><h4 class="lighter smaller">企业产品列表</h4></div>
                    <div class="widget-body">
                        <div class="widget-main padding-8">
                            <div id="treeDemo" class="ztree"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="table_menu_list">
            <table class="table table-striped table-bordered table-hover" id="sample-table" style="width:100%">
                <thead>
                <tr>
                    <th width="60px" style="width:60px!important;">序号</th>
                    <th  width="60px" style="width:60px!important;">产品名称</th>
                    <th  width="60px" style="width:60px!important;">原价格（元）</th>
                    <th  width="60px" style="width:60px!important;">库存件数</th>
                    <th width="60px"  style="width:60px!important;">加入时间</th>
                    <th  width="60px" style="width:60px!important;">审核状态</th>
                </tr>
                </thead>
                <tbody>
                </tbody>
            </table>
        </div>
    </div>
</div>
</div>
</div>


<div class="Store_Introduction" style="display: none;" id="typediv1">
    <div class="title_name">供应商操作</div>
    <br/><br/>
    <div class="form-group">
        <label class="col-sm-1 control-label no-padding-right" for="form-field-1"><i></i>上传合同： </label>
        <input type="file" style="margin-left:150px;" onchange="previewImage(this)"/>
    </div>
    <div class="form-group">
        <label class="col-sm-1 control-label no-padding-right" for="form-field-1"><i></i>签订日期： </label>
        <div class="col-sm-9"><input class="inline laydate-icon" id="start1" style=" margin-left:10px;width:300px">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-1 control-label no-padding-right" for="form-field-1"><i></i>到期时间： </label>
        <div class="col-sm-9"><input class="inline laydate-icon" id="start2" style=" margin-left:10px;width:300px">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-1 control-label no-padding-right" for="form-field-1"><i></i>合同名称： </label>
        <div class="col-sm-9"><input type="text" style=" width:300px" class="col-xs-10"></div>
    </div>
    <div class="form-group">
        <label class="col-sm-1 control-label no-padding-right" for="form-field-1"><i></i>代理产品： </label>
        <div class="col-sm-9"><input type="text" style=" width:300px" class="col-xs-10"></div>
    </div>
    <div class="form-group">
        <label class="col-sm-1 control-label no-padding-right" for="form-field-1"><i></i>添加备注： </label>
        <div class="col-sm-9"><input type="text" style=" width:300px" class="col-xs-10"></div>
    </div>
    <br/>
</div>
<br/><br/>
<div class="At_button">
    <button onclick="through_save();" id="success" th:value="${par.company.id}" class="btn btn-primary radius" type="submit">通 过</button>
    <button onclick="cancel_save();" id="fail" th:value="${par.company.id}" class="btn btn-danger  btn-warning" type="button">拒 绝</button>
    <button onclick="history.go(-1)" class="btn btn-default radius" type="button">返回上一步</button>
</div>

<br/>
<br/>
<br/>
<br/>
</body>
</html>
<script type="text/javascript">
    function change_jack(that) {
        $(that).parent().next().children().removeClass("disabled");
    };
    $(".save_bc").on("click", function () {
        var int_val = $(this).parent().prev().children().val();
        $(this).removeClass("btn-primary").addClass("btn-success");
        if (!int_val.trim()) return;
        $(this).parent().prev().children().val(int_val);
    });

    var txt = $("#intro").text();
    $("#intro").html(txt);
</script>
<script>
    jQuery(function ($) {
        var table = $('#sample-table').dataTable({
            "bStateSave": true,//状态保存
            serverSide: true,   //开始服务器分页
            searching:false,  //关闭搜索框
            aoColumnDefs: [
                {"orderable": false, "aTargets": [0, 1, 2, 3, 4, 5]}// 制定列不参与排序
            ],
            ajax: {
                url : '/products/allNodes',
                type : 'post',
                data : function (d) {
                    var data = $('form').serialize();  //获取查询条件
                    //获取分页信息
                    var searchParams= {
                        start : d.start,
                        length : d.length,
                    };
                    data = data + '&' + $.param(searchParams)+'&companyId='+$('#success').val();
                    return data;
                }
            },
            columns : [
                { "data":"id","createdCell":function (td, cellData, rowData, row, col) {
                        $(td).empty().append(row+1);
                    }},
                { "data": "pname" },
                { "data": "pprice" },
                { "data": "count" },
                { "data": "paddtime" },
                { "data": "astatus" ,"createdCell":function (td, cellData, rowData, row, col) {
                        if(cellData=="1"){
                            $(td).empty().append('<span class="label label-success radius">通过</span>')
                        }else if(cellData=="-1") {
                            $(td).empty().append('<span class="label label-danger radius">未通过</span>')
                        }else $(td).empty().append('<span class="label label-warning radius">待审核</span>')
                    }},
            ]
        });



        $(function(){
            /*******树状图*******/
            var setting = {
                async:{
                    enable: true,
                    url:'/categories/getCategories?companyId='+$('#success').val(),
                    autoParam : [ "id","pid","name"]
                },
                view: {
                    dblClickExpand: true,
                    showLine: false,
                },
                data: {
                    simpleData: {
                        enable: true,
                        idKey: "id",
                        pIdKey: "pid",
                        rootPId: ""
                    }
                },
                callback: {
                    onClick:function (treeId,treeNode,d) {
                        $('#nodeId').val(d.id);
                        table.fnUpdate();
                    }
                }
            };
            $.fn.zTree.init($("#treeDemo"), setting);
            var zTree = $.fn.zTree.getZTreeObj("tree");
        });

        $('table th input:checkbox').on('click', function () {
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
                .each(function () {
                    this.checked = that.checked;
                    $(this).closest('tr').toggleClass('selected');
                });
        });

        $('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});

        function tooltip_placement(context, source) {
            var $source = $(source);
            var $parent = $source.closest('table')
            var off1 = $parent.offset();
            var w1 = $parent.width();

            var off2 = $source.offset();
            var w2 = $source.width();

            if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2)) return 'right';
            return 'left';
        }
    });
    $(function () {
        $("#products_style").fix({
            float: 'left',
            //minStatue : true,
            skin: 'green',
            durationTime: false,
            spacingw: 30,//设置隐藏时的距离
            spacingh: 260,//设置显示时间距
        });
    });
</script>
<script type="text/javascript">
    //初始化宽度、高度
    $(".widget-box").height($(window).height() - 215);
    $(".table_menu_list").width($(window).width() - 260);
    $(".table_menu_list").height($(window).height() - 215);
    //当文档窗口发生改变时 触发
    $(window).resize(function () {
        $(".widget-box").height($(window).height() - 215);
        $(".table_menu_list").width($(window).width() - 260);
        $(".table_menu_list").height($(window).height() - 215);
    })
    //面包屑返回值
    var index = parent.layer.getFrameIndex(window.name);
    parent.layer.iframeAuto(index);
    $('.Order_form').on('click', function () {
        var cname = $(this).attr("title");
        var chref = $(this).attr("href");
        var cnames = parent.$('.Current_page').html();
        var herf = parent.$("#iframe").attr("src");
        parent.$('#parentIframe').html(cname);
        parent.$('#iframe').attr("src", chref).ready();
        ;
        parent.$('#parentIframe').css("display", "inline-block");
        parent.$('.Current_page').attr({"name": herf, "href": "javascript:void(0)"}).css({
            "color": "#4c8fbd",
            "cursor": "pointer"
        });
        parent.layer.close(index);

    });
</script>
<script>
    //通过
    var index = parent.layer.getFrameIndex(window.name);
    parent.layer.iframeAuto(index);

    function through_save() {
        layer.confirm('确认要通过该申请吗？', function (index) {
            if ($('#aba').val()=='0'){
                parent.layer.msg('已通过!', {icon: 1, time: 2000});
                parent.$('#parentIframe').css("display", "none");
                parent.$('.Current_page').css({"color": "#333333"});
                //在合作表中添加数据，该公司为客户，我为供应商，将该公司的ID传递过去
                location.href = "/par/acceptCus?companyId="+$('#success').val()+'&intro='+$('#intro').text()+'&relations='+$('#aba').val();
            }
            if ($('#abb').val()=='1'){
                layer.msg('已通过!', {icon: 1, time: 1000});
                parent.$('#parentIframe').css("display", "none");
                parent.$('.Current_page').css({"color": "#333333"});
                //在合作表中添加数据，该公司为客户，我为供应商，将该公司的ID传递过去
                location.href = "/par/acceptSup?companyId="+$('#success').val()+'&intro='+$('#intro').text()+'&relations='+$('#aba').val();
            }
        });


    }

    //返回操作
    function return_close() {
        location.href = "clientele_auditing.html";
        parent.$('#parentIframe').css("display", "none");
        parent.$('.Current_page').css({"color": "#333333"});

    }

    //拒绝
    function cancel_save() {
        var index = layer.open({
            type: 1,
            title: '内容',
            maxmin: true,
            shadeClose: false,
            area: ['600px', ''],
            content: ('<div class="shop_reason"><span class="content">请说明拒绝该申请的理由。</span><textarea name="请填写拒绝理由" class="form-control" id="form_textarea" placeholder="请填写拒绝理由" onkeyup="checkLength(this);"></textarea><span class="wordage">剩余字数：<span id="sy" style="color:Red;">500</span>字</span></div>'),
            btn: ['确定', '取消'],
            yes: function (index, layero) {
                var desc=$('.form-control').val();
                if ($('.form-control').val() == "") {
                    layer.alert('回复内容不能为空！', {
                        title: '提示框',
                        icon: 0,
                    })
                } else {
                    location.href = "/par/refuseApply?Id="+$('#id').text()+'&desc='+desc+'&relations='+$('#aba').val();
                    parent.layer.msg('提交成功!', {icon: 1, time: 1000});
                    parent.layer.close(index);
                }
            }
        })
    }

    /*字数限制*/
    function checkLength(which) {
        var maxChars = 500; //
        if (which.value.length > maxChars) {
            layer.open({
                icon: 2,
                title: '提示框',
                content: '您输入的字数超过限制!',
            });
            // 超过限制的字数了就将 文本框中的内容按规定的字数 截取
            which.value = which.value.substring(0, maxChars);
            return false;
        } else {
            var curr = maxChars - which.value.length; //减去当前输入的
            document.getElementById("sy").innerHTML = curr.toString();
            return true;
        }
    };
</script>

